package com.token.utils;

import com.google.common.collect.Lists;
import com.token.model.dto.Person;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

/**
 * @auther: henriy
 * @Date: 2024/7/4
 */
public class NextDataTest {

    public static void main(String[] args) {
        List<Person> personList = Lists.newArrayList();

        int ageParam = 2;
        for (int i = 0; i < 5; i++) {
            Person person = new Person();
            person.setSex("男");
            person.setAge(i);
            person.setName("" + i);
            personList.add(person);
        }

        System.out.println("personList---" + personList);

        Person maxPerson = personList.stream()
                .max(Comparator.comparing(Person::getAge))
                .orElse(null);
        System.out.println("maxPerson---" + maxPerson);

        for (int i = 0; i < personList.size(); i++) {
            Person person = personList.get(i);
            Integer age2 = person.getAge();

            if(ageParam == age2){
                // 判断当前人是不是年龄最大的
                Integer age = maxPerson.getAge();
                if (!Objects.equals(age, age2)) {
                    Person person1 = personList.get(i + 1);
                    System.out.println("person1---" + person1);
                }
            }
        }


    }

}
